package com.common;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.ext.handler.ContextPathHandler;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
import com.jfinal.plugin.activerecord.SqlReporter;
import com.jfinal.plugin.activerecord.dialect.OracleDialect;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.plugin.ehcache.EhCachePlugin;
import com.jfinal.render.ViewType;
import com.service.Index;


public class ServerConfig extends JFinalConfig
{
   @Override
public void configConstant(Constants me)
   {
		me.setDevMode(true);

		me.setEncoding("utf-8");

		me.setViewType(ViewType.JSP);
		loadPropertyFile("jfinal.properties");
   }
 

   /**
	 * 路由控制
	 */		
   @Override
   public void configRoute(Routes me)
   {
	   me.add("/service/index",Index.class,"/view");//BaseCtrl
   }
 

   /**
	 * 数据库映射关�?
	 */		
	@Override
	public void configPlugin(Plugins me) {
		C3p0Plugin cp = new C3p0Plugin(getProperty("jdbcUrl"),getProperty("user"), getProperty("password").trim());
//		cp.setDriverClass(getProperty("driver"));
		me.add(cp);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);
		arp.setShowSql(true);
		SqlReporter.setLog(true);
		me.add(arp);
		arp.setContainerFactory(new CaseInsensitiveContainerFactory(true));
		
		
		me.add(arp);
	}
 

	/**
	 * 过滤�?
	 */		
	@Override
	public void configInterceptor(Interceptors me) 
	{ 
//		me.addGlobalActionInterceptor(new ExceptionInter());// 异常过滤�?
//		me.addGlobalActionInterceptor(new AdminInter());//用户登录过滤
	}
 
   @Override
   public void configHandler(Handlers hand)
   {
		hand.add(new ContextPathHandler("basePath"));
   }

   @Override
   public void afterJFinalStart()
   {
     super.afterJFinalStart();
   }
   
 //在系统停止时调用的方�? // 系统关闭之前回调
   @Override
   public void beforeJFinalStop() {
	   super.beforeJFinalStop();
   };
   
   
}
